package top.go2do.common.filter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description
 * @Author xingyj
 * @CreateTime 2025/3/25 12:50
 */

@Configuration
public class FilterConfig {

    @Autowired
    private TokenFilter tokenFilter;

    @Bean
    public FilterRegistrationBean<TokenFilter> tokenFilterRegistration() {
        FilterRegistrationBean<TokenFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(tokenFilter);
        registration.addUrlPatterns("/*"); // 过滤所有请求
        registration.setName("tokenFilter");
        registration.setOrder(1); // 设置过滤器顺序
        return registration;
    }

}